//
//  OADTableConfig.m
//  OASDK_Works
//
//  Created by ChenJie on 3/1/20.
//  Copyright © 2020 Mist. All rights reserved.
//

#import "OADTableConfig.h"

@interface OADTableConfig ()

@end

@implementation OADTableConfig

#pragma mark - Lifecycle methods

- (instancetype)init {
    self = [super init];
    if (self) {
    }
    return self;
}

#pragma mark - Public methods

- (OADSectionConfig *)sectionConfigAtIndex:(NSInteger)sectionIndex {
    if (self.sections.count <= sectionIndex) {
        return nil;
    }
    return self.sections[sectionIndex];
}

/*
 * UITableViewDataSource
 */

- (NSInteger)numberOfSectionsInTableView {
    return self.sections.count;
}

- (NSInteger)numberOfRowsInSection:(NSInteger)section {
    OADSectionConfig *sectionConfig = [self sectionConfigAtIndex:section];
    return [sectionConfig numberOfRowsInSection];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    OADSectionConfig *sectionConfig = [self sectionConfigAtIndex:indexPath.section];
    return [sectionConfig tableView:tableView cellForRowAtIndex:indexPath.row];
}

/*
 * UITableViewDelegate
 */

- (CGFloat)heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    OADSectionConfig *sectionConfig = [self sectionConfigAtIndex:indexPath.section];
    return [sectionConfig heightForRowAtIndex:indexPath.row];
}

#pragma mark - Private methods



#pragma mark - Delegate methods



#pragma mark - Setter



#pragma mark - Getter

- (NSMutableArray<OADSectionConfig *> *)sections {
    if (!_sections) {
        NSMutableArray *array = [NSMutableArray array];
        _sections = array;
    }
    return _sections;
}

#pragma mark - Memory management methods

- (void)dealloc {
}

@end
